/*
 * blink.c
 *
 *  Created on: Jun 11, 2012
 *      Author: Vasile Guta Ciucur
 *      Code size: - see the following comment and experiment for yourself.
 */
#ifndef F_CPU
#define F_CPU 16000000U //required by Atmel Studio 6
#endif

// You don't need to activate any definition in "atmegaclib.h" header - comment
// them all.

#include <avr/io.h>
#include <util/delay.h>
#include <atmegaclib.h>

//Program modified for portability with Sanguino and other Arduino boards.
//For maximum reduction of code size use sbi() and cbi() macros directly as
// in the commented zone of the code bellow. Every function call add some
// weight to the code. Maybe to much weight - comment one and uncomment the
// another zone, to experiment for yourself.

// By the way, no one is forcing you to write portable code so, your code can
// be cleaner than this.

///*
void main(void) __attribute__((noreturn));
void main(void) {
	onboard_led_enable(); //set the pin as output
	for (;;) { // infinite loop.
		onboard_led_toggle(); // set pin high
		_delay_ms(500); // delay 250 milliseconds (0.25 seconds)
	}
}

//*/

/*
 // Usage of the sbi/cbi macros directly.
 void main(void) __attribute__((noreturn));
 void main (void)
 {
 // set the digital pin as output
 #if defined(__AVR_ATmega32__) || \
      defined(__AVR_ATmega16__) || \
      defined(__AVR_ATmega164P__) || \
      defined(__AVR_ATmega324P__) || \
      defined(__AVR_ATmega164PA__) || \
      defined(__AVR_ATmega324PA__) || \
      defined(__AVR_ATmega164__) || \
      defined(__AVR_ATmega324__) || \
      defined(__AVR_ATmega644__) || \
      defined(__AVR_ATmega644P__) || \
      defined(__AVR_ATmega644PA__) || \
      defined(__AVR_ATmega1284P__) || \
      defined(__AVR_ATmega1284__) // Sanguino
 sbi(DDRB, 0); // DEBUG LED, used also for bootloader
 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Arduino Mega1280
 sbi(DDRB, 7);
 #elif defined(__AVR_ATmega48__)   || \
      defined(__AVR_ATmega88__)      || \
      defined(__AVR_ATmega88P__)     || \
      defined(__AVR_ATmega168__)     || \
      defined(__AVR_ATmega168P__)    || \
      defined(__AVR_ATmega328P__) // Arduino 28 pins
 sbi(DDRB, 5);
 #endif

 for (;;){            // infinite loop.
 // toggle the LED pin

 // set the pin low
 #if defined(__AVR_ATmega32__) || \
      defined(__AVR_ATmega16__) || \
      defined(__AVR_ATmega164P__) || \
      defined(__AVR_ATmega324P__) || \
      defined(__AVR_ATmega164PA__) || \
      defined(__AVR_ATmega324PA__) || \
      defined(__AVR_ATmega164__) || \
      defined(__AVR_ATmega324__) || \
      defined(__AVR_ATmega644__) || \
      defined(__AVR_ATmega644P__) || \
      defined(__AVR_ATmega644PA__) || \
      defined(__AVR_ATmega1284P__) || \
      defined(__AVR_ATmega1284__) // Sanguino
 tbi(PORTB, 0); // DEBUG LED, used also for bootloader
 #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Arduino Mega1280
 tbi(PORTB, 7);
 #elif defined(__AVR_ATmega48__)   || \
      defined(__AVR_ATmega88__)      || \
      defined(__AVR_ATmega88P__)     || \
      defined(__AVR_ATmega168__)     || \
      defined(__AVR_ATmega168P__)    || \
      defined(__AVR_ATmega328P__) // Arduino 28 pins
 tbi(PORTB, 5);
 #endif

 _delay_ms(500);    // delay 250 milliseconds (0.25 seconds)

 }
 }
 */
